﻿using System;
class TrapezoidArea
{
    static void Main()
    {
        float sidea = 0.0f;
        float sideb = 0.0f;
        float height = 0.0f;
        Console.Write("Input Side A: ");
        do
        {
            if (sidea != 0)
            {
                Console.Write("Please enter positive number: ");
            }
            while (true)
            {
                try
                {
                    sidea = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message + "\nPlease re-enter Side A: ");
                }
            }
        } while (sidea <= 0);
        Console.Write("Input Side B: ");
        do
        {
            if (sideb != 0)
            {
                Console.Write("Please enter positive number: ");
            }
            while (true)
            {
            try
            {
                sideb = int.Parse(Console.ReadLine());
                break;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message + "\nPlease re-enter Side B: ");
            }
        }
        } while (sideb <= 0);
        Console.Write("Input Height: ");
        do
        {
            if (height != 0)
            {
                Console.Write("Please enter positive number: ");
            }
        while (true)
        {
            try
            {
                height = int.Parse(Console.ReadLine());
                break;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message + "\nPlease re-enter Height: ");
            }
        }
        } while (height <= 0);
        float areaoftrapez = (((sidea + sideb) / 2) * height);
        Console.WriteLine("Side A is: {0}, Side B is: {1} and Height is: {2}", sidea, sideb, height);
        Console.WriteLine("Area of Trapezoid is {0}", areaoftrapez);
        Console.ReadLine();
    }
}

